import { _decorator, Component, Input, input, Node, type EventTouch, type Vec2, type Vec3 } from 'cc'
const { ccclass, property } = _decorator

@ccclass('cameraCtrl')
export class NewComponent extends Component {
  start() {
    input.on(Input.EventType.TOUCH_START, this.onTouchStart, this)
    input.on(Input.EventType.TOUCH_MOVE, this.onTouchMove, this)
  }

  onTouchStart(event: EventTouch) {
    console.log('TOUCH_START', event)
  }

  onTouchMove(event: EventTouch) {
    const moveScale = 0.02
    const position: Vec3 = this.node.position
    this.node.setPosition(
      position.x + event.getDelta().x * moveScale,
      position.y + event.getDelta().y * moveScale,
      position.z,
    )
  }

  update(deltaTime: number) {}
}
